package thinkingJava.chapter11;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class SetOperations {
	public static void main(String[] args) {
		Set<String> set1 = new HashSet<String>();
		Collections.addAll(set1, "A B C D E F G H I J K L".split(" "));
		print(set1);
		set1.add("M");
		print(set1);
		print(set1.size());
		set1.add("abc");
		print(set1.contains("abc"));
		print(set1.contains("ab"));
		Set<String> set2 = new HashSet<String>();
		Collections.addAll(set2, "H I J K L".split(" "));
		print("set1 contains set2 ? " + set1.containsAll(set2));
		set1.remove("H");
		print(set1);
		print("set2 in set1 ? " + set1.containsAll(set2));
		set1.removeAll(set2);
		print("set2 removed from set1  " + set1);
		Collections.addAll(set1, "X Y Z".split(" "));
		print("x y x added int set1  " + set1);
	}
	public static void print(Object o) {
		System.out.println(o);
	}
}
